/**
 * 评论相关功能封装
 */
import ajax from '@/utils/request.js';

/**
 * 添加评论
 * @param {*} data 参数
 * data:{
 *  target：评论目标id
 *  content
 *  art_id：文章编号
 * }
 */
export const addComment = (data) => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/comments',
    data
  });
};

/**
 * 获取评论
 * @param {*} params
 */
export const getComments = params => {
  return ajax({
    method: 'GET',
    url: '/app/v1_0/comments',
    params
  });
};

/**
 * 对评论点赞
 * @param {*} commentId 评论id
 */
export const addCommentLike = commentId => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/comment/likings',
    data: {
      target: commentId
    }
  });
};

/**
 * 对评论取消点赞
 * @param {*} commentId 评论id
 */
export const deleteCommentLike = commentId => {
  return ajax({
    method: 'DELETE',
    url: '/app/v1_0/comment/likings/' + commentId
  });
};
